tail recursion - определение. Что такое tail recursion
Diclib.com
Словарь ChatGPT
Введите слово или словосочетание на любом языке 👆
Язык:

Перевод и анализ слов искусственным интеллектом ChatGPT

На этой странице Вы можете получить подробный анализ слова или словосочетания, произведенный с помощью лучшей на сегодняшний день технологии искусственного интеллекта:

  • как употребляется слово
  • частота употребления
  • используется оно чаще в устной или письменной речи
  • варианты перевода слова
  • примеры употребления (несколько фраз с переводом)
  • этимология

Что (кто) такое tail recursion - определение

SUBROUTINE THAT CALLS ITSELF AS ITS FINAL ACTION
Tail recursion; Tail recursion modulo cons; Tail-recursive; Tail recursive; Tail call optimization; Tail Recursion; Tail-call optimization; Tailcall; Tail-call optimisation; Tail-call elimination; Tail-recursion; Tail-end recursion; Tail call elimination; Tail recursion elimination; Tail recursion optimization; Tail-recursion optimization; Proper tail recursion; Tail function; Tail recursive function; Tail-recursive function

tail recursion         
<programming> When the last thing a function (or procedure) does is to call itself. Such a function is called tail recursive. A function may make several recursive calls but a call is only tail-recursive if the caller returns immediately after it. E.g. f n = if n < 2 then 1 else f (f (n-2) + 1) In this example both calls to f are recursive but only the outer one is tail recursive. Tail recursion is a useful property because it enables {tail recursion optimisation}. If you aren't sick of them already, see recursion and {tail recursion}. [Jargon File] (2006-04-16)
tail recursion modulo cons         
<programming, compiler> A generalisation of tail recursion introduced by D.H.D. Warren. It applies when the last thing a function does is to apply a constructor functions (e.g. cons) to an application of a non-primitive function. This is transformed into a tail call to the function which is also passed a pointer to where its result should be written. E.g. f [] = [] f (x:xs) = 1 : f xs is transformed into (pseudo C/Haskell): f [] = [] f l = f' l allocate_cons f' [] p = { *p = nil; return *p } f' (x:xs) p = { cell = allocate_cons; *p = cell; cell.head = 1; return f' xs &cell.tail } where allocate_cons returns the address of a new cons cell, *p is the location pointed to by p and &c is the address of c. [D.H.D. Warren, DAI Research Report 141, University of Edinburgh 1980]. (1995-03-06)
Tail call         
In computer science, a tail call is a subroutine call performed as the final action of a procedure. If the target of a tail is the same subroutine, the subroutine is said to be tail recursive, which is a special case of direct recursion.

Википедия

Tail call

In computer science, a tail call is a subroutine call performed as the final action of a procedure. If the target of a tail is the same subroutine, the subroutine is said to be tail recursive, which is a special case of direct recursion. Tail recursion (or tail-end recursion) is particularly useful, and is often easy to optimize in implementations.

Tail calls can be implemented without adding a new stack frame to the call stack. Most of the frame of the current procedure is no longer needed, and can be replaced by the frame of the tail call, modified as appropriate (similar to overlay for processes, but for function calls). The program can then jump to the called subroutine. Producing such code instead of a standard call sequence is called tail-call elimination or tail-call optimization. Tail-call elimination allows procedure calls in tail position to be implemented as efficiently as goto statements, thus allowing efficient structured programming. In the words of Guy L. Steele, "in general, procedure calls may be usefully thought of as GOTO statements which also pass parameters, and can be uniformly coded as [machine code] JUMP instructions."

Not all programming languages require tail-call elimination. However, in functional programming languages, tail-call elimination is often guaranteed by the language standard, allowing tail recursion to use a similar amount of memory as an equivalent loop. The special case of tail-recursive calls, when a function calls itself, may be more amenable to call elimination than general tail calls. When the language semantics do not explicitly support general tail calls, a compiler can often still optimize sibling calls, or tail calls to functions which take and return the same types as the caller.